var ssxForm;
var gxdwForm;

$(init);

function init(){
    $("#listGrid").jqGrid(
    {
        url : ctx+"/common/extQuery?sqlid=capqyxx&modules=A",
        postData : $("#searchForm").getFormJson(),
        autowidth:true,
        height:(($(window.document).height())-150),
        datatype: "json",    
        colNames : ['标题','税源企业','发文时间','采集时间','来源','操作'],
        colModel : [ 
            {name : "TITLE",index : "TITLE",width : 400,sortable:false,formatter:function(value,options,row){
            	var html = "";
            	if(row.INFOID!="0"){
            		html+="<img src='"+ctx+"/static/images/star.png'>";
            	}
            	if(isNew(Date.parse(row.INFODATE.replace(/-/gi,"/")))){
            		html+="<img src='"+ctx+"/static/images/new.png'>";
            	}
            	html += "<a href=\"javascript:showInfDetail('"+row.ID+"','"+row.TITLE+"')\">"+value+"</a>";
            	return html;
            }}, 
            {name : "QYJC",index : "QYJC",width : 100,sortable:false}, 
//            {name : "SSBK",index : "SSBK",width : 100,sortable:false,formatter:function(value,options,row){
//            	if(row.SSBK=="1"){
//            		return "主板上市";
//            	}else if(row.SSBK=="2"){
//            		return "创业板上市";
//            	}else if(row.SSBK=="3"){
//            		return "新三板上市";
//            	}else if(row.SSBK=="4"){
//            		return "Q版上市";
//            	}else{
//            		return "非上市公司";
//            	}
//            }}, 
            {name : "INFODATE",index : "INFODATE",width : 100,align:"center",sortable:false}, 
            {name : "SAVEDATE",index : "SAVEDATE",width : 100,align:"center",sortable:false,formatter:function(value,options,row){
            	return getDateDiff(Date.parse(value.replace(/-/gi,"/")));
            }}, 
            {name : "WEBNAME",index : "WEBNAME",width : 100,sortable:false}, 
        	{name: 'cz', index: 'cz', width: 250, sortable: false, align: "center", title: false, formatter: function (value, options, row) {
                return "<span class='tdcz'>" +
                        "<a title='源网页' class='small_btn tax' href=\"javascript:openUrl('" + row.URL + "');\">源网页</a>" +
                        (row.INFOID=="0"?"<a title='加入收藏' class='small_btn new' href=\"javascript:addFav('" + row.ID+"');\">加入收藏</a>":"<a title='取消收藏' class='small_btn del' href=\"javascript:delFav('" + row.ID+"');\">取消收藏</a>") +
                        "<a title='导出' class='small_btn detailed' href=\"javascript:exportWord('" + row.ID + "','"+row.ID+"');\">导出</a>" +
                        "<a title='推送' class='small_btn zp' href=\"javascript:push('" + row.ID + "');\">推送</a>" +
                        "</span>";
            }}
        ],
        prmNames:{
            rows:"limit"
        },
        jsonReader :{
            root: "message.list",   
            page: "message.pageNumber",   
            total: "message.totalPage",
            records:"message.totalRow"
        },
        loadtext:"<img src='"+ctx+"/static/images/loading.gif'>&nbsp;&nbsp;拼命加载中...",
        rowNum : 50,
        rowList : [ 50, 100, 150 ],
        pager : "#gridPager",
        mtype: "POST",
        viewrecords : true,
        sortable:false
     });
     //自适应屏幕
     $(window).resize(function(){
        $("#listGrid").setGridWidth($(window).width()*0.99);
     });
}

//打开更多条件信息
function openGDTJ(){
    qyOpen("高级搜索",620,"divGdContent");
}

//高级查询
function refreshGridGd(){
    var data = $("#searchFormGd").getFormJson();
    refreshGridByJson(data);
    qyClose();
}

//刷新资源信息
function refreshGrid(){
    var data = $("#searchForm").getFormJson();
    refreshGridByJson(data);
}

function refreshGridByJson(data){
	$("#listGrid").setGridParam({"postData":data}).trigger("reloadGrid",[{page:1}]);
}

//重置
function searchFormReset(){
	formReset("searchForm");
	formReset("searchFormGd");
}
